/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package foldervisualizer;

import com.sun.javafx.runtime.Entry;
import java.util.List;
import javafx.async.RunnableFuture;
import nl.foldervisualizer.*;

/**
 *
 * @author paul
 */
public class VisualizeFuture implements RunnableFuture {

    private final FXListener listener;
    private final String dir;
    

    public VisualizeFuture(final String dir, final FXListener listener) {
        this.listener = listener;
        this.dir = dir;       
    }

    public void run() throws Exception {
        Folder folder = new Folder(dir);
        FolderVisualizer visualizer = FolderVisualizer.create(folder);
        final List<FolderItem> items = visualizer.toVisualize(folder, 5);

        Entry.deferAction(new Runnable() {

            public void run() {
                listener.callback(items);
            }
        });
    }
}
